<?php
/*
       
*/
require_once(PATH_APP.'/Request.class.php');
require_once(PATH_APP.'/index.class.php');

class Application {
      private static $instance;
      
      private function __construct() {
      }
      
      public static function run() {
            $app = Application::getInstance();
            try {
                  $page = Request::getInstance()->getParameter("page");
                  switch ($page) {
                        case 'listOfProducts': break;
                        
                        case '': // uvod
                        default:
                              $page = 'index';
                        break;
                  }
                  $app->runModule($page);
            } catch (Exception $e) {
            }
      }
      
      public static function getInstance() {
            if (is_null(self::$instance)) { 
                  self::$instance = new Application();
            }
            return self::$instance;
      }
      
      private function runModule($name) {
            $evalstring = "\$mod = $name::getInstance();";
            eval($evalstring);
      }
}
?>
